@using Microsoft.AspNetCore.Authorization
@inject IAuthorizationService AuthorizationService

@{
    string culture = ViewBag.culture;
    List<Sio.Cms.Lib.ViewModels.SioPages.ReadListItemViewModel> topCates = SioCmsHelper.GetCategory(Url, ViewBag.culture, SioEnums.CatePosition.Top, Context.Request.Path);
}
<nav class="navbar navbar-expand-lg bg-white fixed-top navbar-transparent" color-on-scroll="500">
    <div class="container">
        <div class="navbar-translate">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#example-navbar-primary" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-bar bar1"></span>
                <span class="navbar-toggler-bar bar2"></span>
                <span class="navbar-toggler-bar bar3"></span>
            </button>
            <a class="navbar-brand" href="https://www.swastika.io" title="siocore">
                <img class="logo-white" src="@(SioService.GetConfig<string>("Logo", ViewBag.culture as string))" width="32" 
                     title="@(SioService.GetConfig<string>("SiteName", ViewBag.culture as string))" 
                     alt="@(SioService.GetConfig<string>("SiteName", ViewBag.culture as string))" />
            </a>
        </div>
        <div class="collapse navbar-collapse" id="example-navbar-primary">
            <ul class="navbar-nav ml-auto">
                @foreach (var cate in topCates.OrderBy(c => c.Priority))
                {
                    string activedClass = cate.IsActived ? "active" : string.Empty;
                    if (cate.Type == SioEnums.SioPageType.Blank)
                    {
                        <li class="dropdown nav-item @activedClass">
                            <a href="@cate.StaticUrl" target="_blank"
                               class="nav-link dropdown-toggle" data-toggle="dropdown" id="dd-@cate.Id">
                                @cate.Title <i class="@cate.Icon"></i>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dd-@cate.Id">
                                @foreach (var childNav in cate.Childs)
                                {
                                    activedClass = childNav.IsActived ? "active" : string.Empty;
                                    <a href="@childNav.Page.DetailsUrl" class="dropdown-item @activedClass">@childNav.Page.Title</a>
                                }
                            </div>
                        </li>
                    }
                    else
                    {
                        <li class="nav-item @activedClass">

                            <a href="@cate.DetailsUrl" class="nav-link">@cate.Title</a>
                        </li>

                    }
                }
                @if (User.Identity.IsAuthenticated)
                {
                    <li class="nav-item">
                        <a class="nav-link" href="/admin">
                            <i class="now-ui-icons ui-2_settings-90"></i>
                            <p>Portal</p>
                        </a>
                    </li>
                }
            </ul>
           
        </div>
    </div>
</nav>
